import Message from '@/components/common/message/message.vue'

export default {
    install(Vue, options) {
        Vue.prototype.$message = function(opts) {
            const MessageConstructor = Vue.extend(Message)
            const messageWrap = document.createElement('div')

            messageWrap.className = 'message-wrap'

            const messageInstace = new MessageConstructor({
                el: messageWrap
            })

            document.body.appendChild(messageInstace.$el)

            if (opts && opts.text) {
                console.log(opts)
                messageInstace.text = opts.text
            }

            if (opts && opts.type) {
                messageInstace.type = opts.type
            }
            messageInstace.show = true
        }
    }
}
